const state = {
  loginState: '0',
  selectGoods: sessionStorage.getItem('selectGoods') ? JSON.parse(sessionStorage.getItem('selectGoods')) : [],
  params: {},
  goodType: sessionStorage.getItem('goodType') ? JSON.parse(sessionStorage.getItem('goodType')) : 'normal',
  apply: {
    level: sessionStorage.getItem('applyLevel') ? sessionStorage.getItem('applyLevel') : '',
    area: sessionStorage.getItem('applyArea') ? sessionStorage.getItem('applyArea') : ''
  }
};
const getters = {
  selectGoods: state => state.selectGoods,
  goodType: state => state.goodType
};
const actions = {};
const mutations = {
  changeSelectGoods(state, selectGoods) {
    sessionStorage.setItem('selectGoods', JSON.stringify(selectGoods));
    state.selectGoods = JSON.parse(sessionStorage.getItem('selectGoods'));
  },
  sendGoodType(state, goodType) {
    sessionStorage.setItem('goodType', JSON.stringify(goodType));
    state.goodType = JSON.parse(sessionStorage.getItem('goodType'));
  },
  applyLevel(state, level) {
    sessionStorage.setItem('applyLevel', level);
    state.apply.level = sessionStorage.getItem('applyLevel');
  },
  applyArea(state, area) {
    sessionStorage.setItem('applyArea', area);
    state.apply.area = sessionStorage.getItem('applyArea');
  }
};

export default {
  state,
  getters,
  actions,
  mutations
};
